package com.umakr.ax.app.web;

import com.umakr.ax.common.service.FavoriteService;
import com.umakr.ax.core.base.AbstractController;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 * 收藏  前端控制器
 * </p>
 *
 * @author Umakr-Code-Generator
 * @since 2017-12-30
 */
@Controller
@RequestMapping("/api/favorite")
public class FavoriteAppController extends AbstractController {

	@Autowired
	FavoriteService favoriteService;

	/**
	 * 获取我的收藏列表
	 * @param modelMap
	 * @param userId
	 * @return
	 */
	@ApiOperation(value = "获取我的收藏列表")
	@GetMapping("/listMyFavoriteByUserId")
	public Object listMyFavoriteByUserId(ModelMap modelMap, Long userId ) {
		return setSuccessModelMap(modelMap,favoriteService.listMyFavoriteByUserId(userId));
	}

	/**
	 * 删除收藏
	 * @param modelMap
	 * @param fvId
	 * @return
	 */
	@ApiOperation(value = "删除收藏")
	@GetMapping("/deleteMyFavorite")
	public Object deleteMyFavorite(ModelMap modelMap, Long fvId ) {
		return setSuccessModelMap(modelMap,favoriteService.deleteMyFavorite(fvId));
	}


	/**
	 * @author 唐腾飞
	 * @param modelMap
	 * @param userId
	 * @param rsId
	 * @param rsName
	 * @param rsLogo
	 * @param universalId
	 * @param turnToUrlName
	 * @param favType
	 * @param favTitle
	 * @param type
	 * @return
	 */
	@ApiOperation(value = "电台秀收藏/取消收藏")
	@GetMapping("/favorite")
	@ResponseBody
	public Object favorite(ModelMap modelMap, Long userId,Long rsId,String rsName,String rsLogo,Long universalId,String turnToUrlName,Integer favType,String favTitle,Integer type) {
		return setSuccessModelMap(modelMap,favoriteService.favorite(userId,rsId,rsName,rsLogo,universalId,turnToUrlName,favType,favTitle,type));
	}
}